/*************************************************
Author: Aven 
Date: 2/25/2013
Description:
Notes: 
*************************************************/

#ifndef __CPetConfig_h__
#define __CPetConfig_h__

#include "CTArray.h"
#include "CPetDef.h"

/*暂时放在这里，在合代码的时候一起分开存放 ------------The start*/

//宠物aven
/*
    ERROR_PET_LEVEL_ADD_EMPTY_CONFIG        =  1600, //宠物等阶配置空
    ERROR_PET_LEVEL_ID                      = 1601, //错误宠物等阶id
    ERROR_PET_LEVEL_DUPLICATED_CONFIG       = 1602, //重复宠物等阶
    ERROR_PET_EXPLORE_EMPTY_CONFIG          = 1603, //宠物探险配置空
    ERROR_PET_EXPLORE_ID                    = 1604, //错误宠物探险id
    ERROR_PET_EXPLORE_DUPLICATED_CONFIG     = 1605, //重复宠物探险
    ERROR_PET_STAR_ADD_EMPTY_CONFIG         = 1606, //添加宠物星级配置空
    ERROR_PET_LEVEL_STAR_CONFIG             = 1607, //宠物等阶星级配置错
    ERROR_PET_LEVEL_STAR_ID                 = 1608, //错误宠物星级id
    ERROR_PET_STAR_DUPLICATED_CONFIG        = 1609, //重复宠物星级配置
    ERROR_PET_TRAIN_GOLD_NUM                = ,     //错误金币培养数
    ERROR_PET_TRAIN_SILVER_NUM              = ,     //错误银币培养数
    ERROR_PET_LEVEL_MAX                     = ,     //宠物等阶达到最大值
    ERROR_PET_TRAIN_NOT_ENOUGH_GOLD         = ,       //没有足够的金币
    ERROR_PET_TRAIN_NOT_ENOUGH_SILVER       = ,       //没有足够的银币

//宠物形态配置
    PET_STATUS_TYPE_OWL                 = 1, //猫头鹰
    PET_STATUS_TYPE_CAT                 = 2, //猫
    PET_STATUS_TYPE_HAMSTER             = 3, //仓鼠
    PET_STATUS_TYPE_DOG                 = 4, //狗

    PETNAME_LEN                         = 64;//宠物昵称最大长度
    MAX_EXPLORE_NUM = 10,              //探险最大数量
    MAX_EXPLORE_AWARD_NUM = 4,      //单次探险的奖励数量
    MAX_PET_LEVEL_CONFIG = 10,      //最多10个等阶
    MAX_PET_STAR_CONFIG = 9,        //星级从0开始，最大值9
    MAX_PET_STAR_CONFIG = 100,      //等阶数*每等阶星级数
    MAX_PET_EXPLORE_NUM = 10,       //最大探险配置数量

    MAX_PET_EXPLORE_DAILY_NUM = 10, //用户每天最多探险次数
    MAX_RATE_VALUE = 1000,          //概率最大分母值
    MAX_DAILY_CRIT_NUM = 3,         //每天前三次暴击剩余次数，初始为最大值3

    CONST_PET_LEVEL_ATTRS = 10,     //等阶属性数量,最多10个
    CONST_PET_CRIT_EXPER = 10,      //宠物培养暴击倍率
//宠物培养类型
    PET_TRAIN_TYPE_1 = 0,       //皇家口粮
    PET_TRAIN_TYPE_2 = 1,       //金币
    PET_TRAIN_TYPE_3 = 2,       //银币
    PET_TRAIN_TYPE_4 = 3,       //果实

    //操作类型
    CONST_PET_EXPLORE = 0,      //宠物探险
    CONST_PET_CHANGE_STYLE = 1, //切换宠物形态
    CONST_PET_RENAME = 2,      //宠物改名

//宠物消息id
    ID_MAIN_GET_PET_INFO = ;      //请求宠物信息
    ID_MAIN_PET_TRAIN = ;     //宠物培养
    ID_MAIN_PET_OTHER = ;    //宠物其他请求信息

class CPetData:public CTCodeObject
{
public:
    int _iPetStyle;      //宠物形态
    int _iPetLevel;      //宠物等阶
    int _iPetStar;       //宠物星级
    int _iPetExper;      //当前星级经验 
    int _iCurTime;       //记录当日探险起始时间
    int _iExploreCountInDay; //当日剩余探险次数,默认为最多次数
    int _iPetFruit;      //吃了多少个果实
    int _iDailyCritNums;    //每天前三次暴击剩余次数，初始为最大值3
    CTLib::CTSizeString<PETNAME_LEN> _sPetName;  //宠物昵称
    CTLib::CTArray<int, MAX_PET_EXPLORE_NUM> _aPetExploreEventList; //每日探险事件列表

public:
    void Clear()
    {
        _iPetStyle = 0;
        _iPetLevel = 0;
        _iPetStar  = 0;
        _iPetExper = 0;
        _iCurTime  = 0;
        _iExploreCountInDay = 0;
        _iPetFruit   = 0;
        _sPetName.Set("");
        _aPetExploreEventList.Clear();
    }
};

BEGIN_CODE_CONVERT(CPetData)
CODE_CONVERT(_iPetStyle ) 
CODE_CONVERT(_iPetLevel ) 
CODE_CONVERT(_iPetStar  ) 
CODE_CONVERT(_iPetExper ) 
CODE_CONVERT(_iCurTime  ) 
CODE_CONVERT(_iExploreCountInDay )
CODE_CONVERT(_iPetFruit )
CODE_CONVERT(_sPetName  )
CODE_CONVERT(_aPetExploreEventList)
END_CODE_CONVERT(CPetData);
*/

/*暂时放在这里，在合代码的时候一起分开存放 ------------The end*/
#define HKOULIANGTYPE 8 
#define HKOULIANGID 169
#define TRAIN_GOLD_NUM 10
#define PET_FRUIT_TYPE 23
//#define PETEXPLORECOOLID 3 
//宠物探险应该达到的级别
#define PETEXPLORENEEDLEVEL 20

class CPetConfig;

class CPetLevelAttr
{
public:
    CPetLevelAttr()
    {
        iAttrId = 0;
        iAttrValue = 0;
    }

public:
    int iAttrId; //属性id
    int iAttrValue; //属性value
};

//宠物等阶属性配置项
class CPetLevelConfigData
{
public:

	CPetLevelConfigData() 
        :_bHasConfig(false)
    {
        _iPetLevel = 0;      
        _aPetLevelAttrs.Clear();
    }

	virtual ~CPetLevelConfigData() 
    {
	}

    void Clear() {_bHasConfig = false;}
    bool HasConfig() const {return _bHasConfig;}

public:
    bool _bHasConfig;       //该config对象是否有有效值

    int _iPetLevel;          //宠物等阶
    CTLib::CTArray<CPetLevelAttr, CONST_PET_LEVEL_ATTRS> _aPetLevelAttrs;  //等阶属性
};

//宠物冷却时间配置
class CExploreCDTimeConfigData
{
public:
	CExploreCDTimeConfigData() 
        :_bHasConfig(false)
    {
        _iExploreId = 0;      
        _iDelayTimes = 0;
    }

	virtual ~CExploreCDTimeConfigData() 
    {
	}

    void Clear() {_bHasConfig = false;}
    bool HasConfig() const {return _bHasConfig;}

public:
    bool _bHasConfig;       //该config对象是否有有效值

    int _iExploreId;          //宠物探险次数
    int _iDelayTimes;           //延迟时间
};

class CPetStarConfigData
{
public:
    CPetStarConfigData()
        :_bHasConfig(false)
    {
        _iPetLevel        = 0; 
        _iPetStar         = 0; 
        _iPhyAttack       = 0; 
        _iMagicAttack     = 0; 
        _iPhyDefend       = 0; 
        _iMagicDefend     = 0; 
        _iNeedExp         = 0; 
        _iTrainSilver     = 0; 
        _iSilverExp       = 0; 
        _iSilverCrit      = 0; 
        _iTrainGold       = 0; 
        _iGoldExp         = 0; 
        _iGoldCrit        = 0; 
        _iGoldBigCrit     = 0; 
    }
    
    virtual ~CPetStarConfigData()
    {
    }

    void Clear() {_bHasConfig = false;}
    bool HasConfig() const {return _bHasConfig;}

public:
    bool _bHasConfig;

    int _iPetLevel;         //宠物等阶
    int _iPetStar;          //宠物星级
    int _iPhyAttack;        //物理攻击
    int _iMagicAttack;      //魔法攻击
    int _iPhyDefend;        //物理防御
    int _iMagicDefend;      //魔法防御
    int _iNeedExp;          //升级需要经验值
    int _iTrainSilver;      //银币培养数
    int _iSilverExp;        //银币培养获得经验
    int _iSilverCrit;       //银币培养暴击率
    int _iTrainGold;        //培养所需金币
    int _iGoldExp;          //金币培养获得经验
    int _iGoldCrit;         //金币培养暴击率
    int _iGoldBigCrit;      //金币培养大暴击率
};

class CPetExploreConfigData
{
    friend class CPetConfig;
public:
    CPetExploreConfigData()
        :_bHasConfig(false)
    {
        _iExploreId = 0;
        _aTExploreAwards.Clear();
    }

    virtual ~CPetExploreConfigData()
    {
    }

    struct TExploreAward
    {
        int iAwardItemType;
        int iAwardItemId;
        int iAwardNum;
    };

    void Clear() {_bHasConfig = false;}
    bool HasConfig() const {return _bHasConfig;}

public:
    bool _bHasConfig;

    int _iExploreId;           //探险id

    CTLib::CTArray<TExploreAward, MAX_EXPLORE_AWARD_NUM> _aTExploreAwards; //当前探险奖励, 最多4个数量
};

//宠物配置
class CPetConfig
{
public:
	CPetConfig() 
    {
	}

	virtual ~CPetConfig() 
    {
	}

    int Init();

    int GetPetLevelConfig(int iPetLevel, CPetLevelConfigData& stData);

    int GetPetStarConfig(int iPetLevel, int iPetStar, CPetStarConfigData& stData);

    int GetPetExploreConfig(int iExploreId, CPetExploreConfigData& stData);
    int GetPetExploreConfigCounts();

    int AddPetExploreConfig( CPetExploreConfigData& stData );

    int AddPetStarConfig( CPetStarConfigData& stData);

    int AddPetLevelConfig(CPetLevelConfigData& stData);

    int AddExploreCDtimeConfig( CExploreCDTimeConfigData& stData);

    int GetExploreCDTimeConfig(int iExploreId, CExploreCDTimeConfigData& stData);

private:
    int _iMaxExploreEventCounts;    //探险事件实际配置个数, -1表示没有计算实际值
    CTLib::CTArray<CPetLevelConfigData, MAX_PET_LEVEL_CONFIG+1>         _astPetLevelConfigs;        //宠物等阶配置
    CTLib::CTArray<CPetStarConfigData, MAX_PET_STAR_CONFIG+1>           _astPetStarConfigs;   //宠物星级配置
    CTLib::CTArray<CPetExploreConfigData, MAX_EXPLORE_CONFIG_NUM+1>        _astPetExploreConfigs;      //宠物探险奖励配置
    CTLib::CTArray<CExploreCDTimeConfigData, MAX_PET_EXPLORE_NUM+1>        _astPetExploreCDTimesConfigs;      //宠物探险冷却时间配置
};

#endif // __CPetConfig_h__

